package com.accp.biz.impl;

import com.accp.biz.EmpBiz;
import com.accp.dao.EmpDao;
import com.accp.pojo.Emp;

import java.util.List;

public class EmpBizImpl implements EmpBiz {

    private EmpDao empDao;

    public void setEmpDao(EmpDao empDao) {
        this.empDao = empDao;
    }


    @Override
    public List<Emp> fandAll(String className, int pageNo, int pageSize, Emp emp) {
        return empDao.fandAll(className,pageNo,pageSize,emp);
    }

    @Override
    public int totalPage(String className, String name) {
        return empDao.totalPage(className,name);
    }
    /**
     * 查看下一页
     */
    @Override
    public int searchRecordsNextPage(int pageSize, String className,Emp emp) {
        int total = empDao.totalPage(className,emp.getName());
        int pageNo = total / pageSize;
        if(total % pageSize > 0){
            pageNo++;
        }
        return pageNo;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public boolean deleteEmp(Integer id) {
        empDao.deleteEmp(id);
        return true;
    }

    /**
     * 添加
     * @param emp
     * @return
     */
    @Override
    public boolean add(Emp emp) {
        empDao.add(emp);
        return true;
    }

    @Override
    public Emp fandEmpById(Integer id) {
        return empDao.fandEmpById(id);
    }

    @Override
    public boolean update(Emp emp) {
        return empDao.update(emp);
    }
}
